package com.woniu.humanresource.service.impl;


import com.woniu.humanresource.dao.MobilizeDao;
import com.woniu.humanresource.dao.MobilizeImgDao;
import com.woniu.humanresource.entity.Mobilize;
import com.woniu.humanresource.entity.MobilizeImg;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.MobilizeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class MobilizeServiceImpl implements MobilizeService {
    @Resource
    MobilizeDao mobilizeDao;
    @Resource
    MobilizeImgDao mobilizeImgDao;

    @Override
    public void insertMobilize(Mobilize mobilize) {
        mobilizeDao.insertMobilize(mobilize);
    }


    @Override
    public PageBean<Mobilize> selectCondition(Mobilize mobilize, int pageIndex, int pageSize) {
//        查询异动信息列表
        List<Mobilize> mobilizes = mobilizeDao.selectCondition(mobilize, pageIndex, pageSize);
//        封装为PageBean对象，并设置属性
        PageBean<Mobilize> pageBean=new PageBean<>();
        pageBean.setBeanList(mobilizes);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectConditionCount(mobilize));
        return pageBean;
    }

    @Override
    public int selectConditionCount(Mobilize mobilize) {
        int count = mobilizeDao.selectConditionCount(mobilize);

        return count;
    }

    @Override
    public void deleteMobilize(int id) {
        mobilizeDao.deleteMobilize(id);
    }

    @Override
    public void updateMobilize(Mobilize mobilize) {
        mobilizeDao.updateMobilize(mobilize);
    }

    @Override
    public void deleteMobilizeImg(int id) {
        mobilizeImgDao.deleteMobilizeImg(id);
    }

    @Override
    public void insertMobilizeImg(MobilizeImg mobilizeImg) {
        mobilizeImgDao.insertMobilizeImg(mobilizeImg);
    }
}
